package features;

import j3d.InvalidBooleanOperationException;

import java.io.File;

import javax.swing.tree.DefaultMutableTreeNode;
import javax.vecmath.Color3f;

import CAD.MainFrame;

import operationSolids.CSGSolid;
import operationSolids.CompoundSolid;
import operationSolids.OperationBlock;

import operationSolids.OperationPocket;

public class PlanarFloorPocket extends Feature{

	int type;
	Feature Mae;
	float radius; 
	float d1; 
	float d2;
	float depth; 
	
	
	public PlanarFloorPocket(int type, Feature Mae, float d1, float d2,
			float depth, float posX, float posY, float posZ,
			float radius,String name,int face) {
		super(type, Mae,name);
		this.Mae = Mae;
		this.d1 = d1;
		this.d2 = d2;
		this.depth = depth;
		this.radius = radius;
		this.type = type;
		this.name = name;
		
		feature=new OperationPocket(name, d1, d2, depth, radius);
		feature.rotate(0, 0, 0);
		create(posX, posY, posZ, face);
		MainFrame.features.add(this);
		MainFrame.refreshJTree();
	}

	public int getType() {
		return type;
	}

	public Feature getMae() {
		return Mae;
	}

	public float getRadius() {
		return radius;
	}

	public float getD1() {
		return d1;
	}

	public float getD2() {
		return d2;
	}

	public float getDepth() {
		return depth;
	}

	public CSGSolid getPocket() {
		return feature;
	}

	@Override
	void translate() {
		feature.translate(placement.getX(), placement.getZ() - depth/2,-placement.getY() );
		switch (MainFrame.Face) {
		case MainFrame.BACKFACE:
			feature.translate(-MainFrame.block.width/2, MainFrame.block.length/2,MainFrame.block.height/2);
			break;
		case MainFrame.FRONTFACE:
			feature.translate(-MainFrame.block.width/2, MainFrame.block.length/2,MainFrame.block.height/2);
			break;
		case MainFrame.EASTFACE:
			feature.translate(-MainFrame.block.length/2,MainFrame.block.width/2,MainFrame.block.height/2 );
			break;
		case MainFrame.WESTFACE:
			feature.translate(-MainFrame.block.length/2,MainFrame.block.width/2,MainFrame.block.height/2 );
			break;
		case MainFrame.LOWERFACE:
			feature.translate(-MainFrame.block.width/2, MainFrame.block.height/2,MainFrame.block.length/2);
			break;
		case MainFrame.TOPFACE:
			feature.translate(-MainFrame.block.width/2, MainFrame.block.height/2,MainFrame.block.length/2);
			break;

		default:
			System.out.println("erro");
			break;
		}
	}

	@Override
	void compound() {
		MainFrame.block  = new Block ("comp", CompoundSolid.DIFFERENCE, MainFrame.block, feature);
	}

	@Override
	public void drawNode(DefaultMutableTreeNode node) {
		node.add(
				new DefaultMutableTreeNode(
				"Radius:"+radius+"mm")
				);
		node.add(
				new DefaultMutableTreeNode(
				"Depth:"+depth+"mm")
				);
		node.add(
				new DefaultMutableTreeNode(
				"D1:"+d1+"mm")
				);
		node.add(
				new DefaultMutableTreeNode(
				"D2:"+d2+"mm")
				);
		
	}
}

	


